﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;
using Truextend.Training.Service;
using Microsoft.SharePoint;
using System.Net.Mail;

namespace Truextend.Training.Schedulers
{
    public class SendInstanceReminderEmailTimerJob : SPJobDefinition
    {
        public SendInstanceReminderEmailTimerJob():base()
        {
        }

        public SendInstanceReminderEmailTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType):
            base(jobName, service, server, targetType)
        {
            
        }

        public SendInstanceReminderEmailTimerJob(string jobName, SPWebApplication webApplication)
            : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
        {
            this.Title = "Send Instance Reminder Email Timer Job";
        }

        public override void Execute(Guid targetInstanceId)
        {
            //base.Execute(targetInstanceId);
            Guid siteGuid = new Guid(this.Properties["SiteGuid"].ToString());
            SPSite site = new SPSite(siteGuid);

            EmailService.SendInstanceReminderEmail(site);
        }
    }
}
